package vns.server.domain;

import java.util.Date;
import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import vns.shared.RuleActionDTO;
import vns.shared.ActivityDTO;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")

public class Activity {
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key id;	
	
	@Persistent
	private String type;	
	@Persistent
	private String describe;	
	@Persistent
	private Date date;
	@Persistent
	private Set<String> objectfrom;	
	@Persistent
	private Set<String> objectto;
	
	public Activity(ActivityDTO activityDTO){
		this.type=activityDTO.getType();
		this.describe=activityDTO.getDescribe();
		this.date=activityDTO.getDate();
		this.objectfrom=activityDTO.getObjectfrom();
		this.objectto= activityDTO.getObjectto();
	}
	
	public void updateFromDTO(ActivityDTO activityDTO){
		this.type=activityDTO.getType();
		this.describe=activityDTO.getDescribe();
		this.date=activityDTO.getDate();
		this.objectfrom=activityDTO.getObjectfrom();
		this.objectto= activityDTO.getObjectto();
	}
	
	public ActivityDTO toDTO(){
		ActivityDTO activityDTO=new ActivityDTO(this.id,this.type,this.describe,this.date,this.objectfrom,this.objectto);
		return activityDTO;
	}
	
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
	
	public Set<String> getObjectfrom() {
		return objectfrom;
	}
	
	public void setObjectfrom(Set<String> Objectfrom) {
		this.objectfrom = Objectfrom;
	}

	public void addObjectfrom(String Objectfrom) {
		this.objectfrom.add(Objectfrom);
	}
	
	public void removeObjectfrom(String Objectfrom){
		this.objectto.remove(Objectfrom);
	}	
	
	public String getDescribe() {
		return describe;
	}

	public void setDescribe(String describe) {
		this.describe = describe;
	}
	
	public Set<String> getObjectto() {
		return objectto;
	}
	
	public void setObjectto(Set<String> Objectto) {
		this.objectto = Objectto;
	}

	public void addObjectto(String Objectto) {
		this.objectto.add(Objectto);
	}
	
	public void removeObjectto(String Objectto){
		this.objectto.remove(Objectto);
	}

	public Key getId(){
		return this.id;
	}
	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}

}
